# -*- coding: utf-8 -*-
from django.conf import settings
from django.core.handlers.wsgi import WSGIRequest


DATE_TIME_FMT = "%Y-%m-%d %H:%m:%S"


def get_current_domain_name(request: WSGIRequest):
    return request.scheme + "://" + request.get_host()


def nround(num, ndigits):
    if num is None:
        return None
    return round(num, ndigits)


def get_url(req: WSGIRequest, uri: str) -> str:
    if uri.startswith(("http://", "https://")):
        return uri
    return  get_current_domain_name(req) + settings.STATIC_URL + uri